<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta charset="UTF-8"></meta>
    <#include "include/common.html">
        <link rel="stylesheet" href="${absolutePath}/page/mobile/css/spitslot.css?version=20160128"/>
        </head>
<body>
<div class="header" id="header">发布吐槽</div>
<div class="main">
    <div class="send-spit">
        <div class="send-spit-input">
            <textarea placeholder="今天你吐槽了吗？" id="spit-slot-area"></textarea>
            <p><a href="javascript:;" class="btn btn-big" id="post-btn">发布吐槽</a></p>
        </div>
    </div>
</div>
<div class="footer">
    <ul>
        <li><a href="${absolutePath}/mobile/sign_in">签到</a></li>
        <li><a href="${absolutePath}/mobile/mobile_spitslot_post.action"></a></li>
        <li class="active"><a href="${absolutePath}/mobile/mobile_spitslot">吐槽</a></li>
    </ul>
</div>
</body>
<script type="text/javascript">
    ulewo.url = {
        loadSpitSlot: ulewo.absolutePath + "/loadSpitSlot", saveSpitSlot: ulewo.absolutePath + "/addSpitSlot.action"
    }
    $(function () {
        ;
        $("#spit-slot-area").css({"width": $(window).width() - 30 + "px"});

        $("#post-btn").click(function () {
            postSpitSlot();
        });
    });

    function postSpitSlot() {
        if (ulewo.user.userId == "") {
            var url = ulewo.curUrl;
            url = encodeURI(url);
            document.location.href = "../login?redirect=" + url;
            return;
        }
        var content = $.trim($("#spit-slot-area").val());
        var imageArry = [];
        var imageItems = $("#image-con .imageItem");
        for (var i = 0, _len = imageItems.length; i < _len; i++) {
            imageArry.push(imageItems.eq(i).attr("data"));
        }
        if (content == "") {
            ulewo.tipMsg({
                type: "warn", content: "吐槽内容不能为空", timeout: 1500
            });
            return;
        }
        if (content.length > 1000) {
            ulewo.tipMsg({
                type: "warn", content: "吐槽内容不能超过1000", timeout: 1500
            });
            return;
        }
        ulewo.ajaxRequest({
            url: ulewo.url.saveSpitSlot, data: {
                content: content, imageUrl: imageArry.join("|")
            }, fun: function (res) {
                ulewo.tipMsg({
                    type: "success", content: "2分已到碗里", timeout: 1500, fun: function () {
                        document.location.href = ulewo.absolutePath + "/mobile/mobile_spitslot"
                    }
                });
            }
        });
    }
</script>
</html>
